/*
 * @Description: 路由配置
 * @Author: liushuang
 * @Date: 2022-03-24 15:21:58
 * @LastEditTime: 2022-12-02 18:09:36
 */
/*
 * alwaysShow: true, // 父路由的children只有一级，也要展示父路由，不然只展示children
 * meta配置: {
 *   title: 菜单名
 *   icon: 菜单icon
 *   hidden: 是否隐藏菜单 默认false
 *   keepAlive: 页面是否缓存 默认false
 *   round: 菜单是否是圆角按钮 默认false
 *   suspension: 侧边栏是否悬浮 默认false
 *   sidebar: 有无侧边栏 默认true(一级路由使用)
 *   padding: 页面有无边距 默认true
 *   style: black 页面样式风格 未写的默认white风格
 *   roles: [] 权限
 * }
 * a是二级路由，a路由下还有子路由，a无需写components
 */
import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/layouts/index.vue'

export const constantRoutes = [
  {
    path: '/login',
    name: 'Login',
    meta: {
      title: '登录',
      hidden: true,
      style: 'black'
    },
    component: () => import('@/views/login/index.vue')
  },
  {
    path: '/404',
    name: '404',
    meta: {
      title: '找不到页面',
      hidden: true
    },
    component: () => import('@/views/error-page/404.vue')
  }
]

export const asyncRoutes = [
  {
    path: '/',
    name: 'dashboard',
    component: Layout,
    meta: {
      title: '可视地图',
      keepAlive: true,
      sidebar: false,
      roles: ['CQU_SECURITY01']
    },
    children: [
      {
        path: '/dashboard',
        name: 'dashboard',
        component: () => import('@/views/dashboard/index.vue'),
        meta: {
          title: '可视地图',
          round: true,
          suspension: true,
          padding: false,
          style: 'black'
        }
      }
    ]
  },
  {
    path: '/history',
    name: 'history',
    component: Layout,
    meta: {
      title: '历史数据',
      icon: 'mdi-home',
      keepAlive: true,
      roles: ['CQU_SECURITY03']
    },
    children: [
      {
        path: '/history-test',
        name: 'history-test',
        meta: {
          title: '测试菜单',
          icon: 'mdi-car',
          roles: ['CQU_SECURITY0303']
        },
        children: [
          {
            path: '/history-test-1',
            name: 'history-test-1',
            meta: {
              title: '测试1'
            },
            component: () => import('@/views/history/test/test1/index.vue')
          },
          {
            path: '/history-test-2',
            name: 'history-test-2',
            meta: {
              title: '测试2'
            },
            component: () => import('@/views/history/test/test2/index.vue')
          }
        ]
      }
    ]
  },
  {
    path: '/:pathMatch(.*)*',
    name: 'not-found',
    redirect: '/404',
    meta: {
      hidden: true
    }
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes
})

export default router
